<div id="main_list" class="span-24 last main">
    <div class="span-18">
        <div class="section_local_ads">
            <? if ($this->ad_type == "give") { ?>
          <h2><?=$this->translate ('Give').' - '.$this->woeidName;?></h2>
      <? }
           if ($this->ad_type == "want") { ?>
          <h2><?=$this->translate ('Want').' - '.$this->woeidName;?></h2>
      <? } ?>

        <?
        if (count ( $this->mensajes ) > 0) {
            echo '<div class="success"><h2>';
            foreach ( $this->mensajes as $msg ) { 
                echo $msg . '<br>';
            }
            echo '</h2></div>';
        }
        ?>
        
        <div class="give-want">
                <a class="<?=(preg_match("/give/", $_SERVER['REQUEST_URI']))?"actual_give-want":"give"?>" href='/<?=$this->lang?>/woeid/<?=$this->woeid?>/give'><?=$this->translate ( 'Give' );?></a>
                &nbsp;
                <a class="<?=(preg_match("/want/", $_SERVER['REQUEST_URI']))?"actual_give-want":"want"?>" href='/<?=$this->lang?>/woeid/<?=$this->woeid?>/want'><?=$this->translate ( 'Want' );?></a>
         </div>
        
        <?php if ($this->ad): ?>
        
        
        <?php 
            echo '<div class="rss">
                        <a class="rss_link" href="http://' . $_SERVER['HTTP_HOST'] .'/'.$this->lang.'/rss/feed/woeid/'.$this->woeid.'/ad_type/'.$this->ad_type.' ">
                        <img alt="rss" src="/images/icons/ico_rss.png" />&nbsp;&nbsp;&nbsp;'.$this->translate('Subscribe via rss to').'&nbsp;'.
                        $this->woeidName.' - '. $this->translate( (string)$this->ad_type ).'</a></div>';
                        
                        if ($this->ad_type == 'give'): ?>
                        <div class="filter_status">
                        <?=$this->partial (  'partials/filter_status_nav.phtml' , array(
                            'woeid' => $this->woeid,
                            'lang' => $this->lang,
                            'ad_type' => $this->ad_type)); ?>
                        </div>
                    <?php endif; ?>

       <?php
       $auth = Zend_Auth::getInstance ();

       foreach ($this->paginator as $key => $val): ?>
        <div class="ad_excerpt">
        
          <?php
              if ($val['photo'] !== null){
                  echo '<div class="ad_list_image">
                    <a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                  <img alt="'.$this->escape($val['title']).'" src="/images/uploads/ads/100/'.
                  $this->escape($val['photo']).'" /></a></div>';
              } else {
                  echo '<div class="ad_list_image">';                 
                  if ($this->lang == 'es') {
                      echo '<a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                    <img alt="'.$this->escape($val['title']).'" src="/images/sin_imagen.jpg" /></a></div>';
                  } else {
                      echo '<a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['id']).'/'.$this->escape($val['title']).' ">
                    <img alt="'.$this->escape($val['title']).'" src="/images/no_image.jpg" /></a></div>';
                  }
                 }
           ?>
        
         <?php
          // if you are the ad owner or admin, then show edit link
          // se quita la hora de ¡lpost H:i:s
          if ($auth->hasIdentity()):
              if ( ($val['user_owner'] == $auth->getIdentity()->id)  || ($this->userRole == 1) ): ?>
                  <div>
                      <a class="ads_section" href="/<?=$this->lang ?>/ad/edit/id/<?=$val['id'] ?>">
                        <?=$this->translate('Edit this ad') ?></a>
                  </div><br />
          <?php endif; endif;?>
    
                <?php if ($val['type'] == 1): ?>
              <span class="ad_status <?=$val['status'] ?>"><?=$this->translate($val['status']) ?></span>
          <?php endif;?>
          
          <div class="ad_excerpt_title"><a class="ad_title_link" href="/<?=$this->lang ?>/ad/show/id/<?=$this->escape($val['id']).'/'.$this->escape($val['title']) ?>">
                 <?=$this->escape($val['title']) ?></a></div>
          
          <span class="ad_date"><?=$this->translate('Posted on '). $this->escape(date( $this->translate('l dS \o\f F Y H:i:s'), strtotime($val['date_created']))) ?>
                  <?=$this->translate('by user ') ?>
                <a class="ads_section" href="/<?=$this->lang ?>/ad/listuser/id/<?=$val['user_owner'] ?>"><?=$this->escape($val['username']) ?></a>
              </span>
                                                        
              <div class="ad_body"><p><?php echo $this->escapeEmail( $this->escape($val['body']) ) ?></p></div>
            
                    <div class="ad_meta_info">
                    <?php if ($val['status'] != 'delivered'): ?>
                        <div class="send_message">
                            <a rel="nofollow" class="ads_section" href="/<?=$this->lang ?>/message/create/id_user_to/<?=$val['user_owner'].'/subject/'.$this->escape($val['title'])
                            ?>">+ <?=$this->translate('Send message to the owner') ?></a></b>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="ads_section" href="/<?=$this->lang ?>/ad/show/id/<?=$this->escape($val['id']).'/'.$this->escape($val['title'])
                            ?>">+ <?=$this->translate('Write a new comment') ?></a></div>
                    <?php endif;?>
            
                    <?php if ($val['readings_count']): ?>
                          <div class="readings_count"><?=$val['readings_count'] . '&nbsp;&nbsp;' .$this->translate('readings') ?></div>
                    <?php endif;?>
            
                    <?php if ($val['comments_count']): ?>
                          <div class="comments_count"><?=', '.$this->escape( $val['comments_count'] == null  ? 0 : $val['comments_count'] ).' '.$this->translate('comments') ?></div>
                    <?php endif;?>
             </div>
           </div>
         <?php endforeach; ?>
    
            <?php else: ?>
                    <div class="no_results">
                        <div class="no_results_txt_strong"><?=$this->translate ( 'No ads to display for this location.');?><br /><br /></div>
                        <div class="no_results_txt"><?=$this->translate ( 'You could try one of these things:');?><br /><br />
                            <span class="no_results_number">1.</span><span class="no_results_txt"><?=$this->translate ( 'Be the first to').' ';?>
                               <a class="no_results_txt_link" href="/<?=$this->lang?>/ad/create"><?=$this->translate ('Post an ad on this location.');?></a><br /><br /></span>
                            <span class="no_results_number">2.</span><span class="no_results_txt"><?=$this->translate ( 'Try to change the location to another city bigger near you.');?><br /><br /></span>
                            <span class="no_results_number">3.</span><span class="no_results_txt"><?=$this->translate ( 'Our autosuggest system (based on your IP) says you are located near:').' '.
                                                '<a class="ads_section" href="/'.$this->lang.'/location/change2/?location='.$this->escape($this->suggestIP).'" > '.$this->suggestIP .'</a>';?></span>
                        
                            </div>
                    </div>
                
                <?php endif;?>

    
            <?php echo $this->paginationControl($this->paginator,
                                                'Sliding',
                                                'partials/paginator_ads.phtml'); ?>

            </div> <!-- /div ads -->
        </div>
        <div class="span-6 last">

                <div class="new_ad_icon">
                    <a class="new_ad" href="/<?=$this->lang ?>/ad/create">
                    <img alt="<?=$this->translate('Create new ad') ?>" src="/images/icons/ico_new_ad.png" class="valign" /><div class="txt_valign"><?=$this->translate('Create new ad'). $this->woeidNameShort ; ?></div></a>
                </div>
                
                <div class="change_location_icon">
                    <a class="change_location" href="/<?=$this->lang ?>/location/change">
                    <img alt="<?=$this->translate('Change location' ) ?>" src="/images/icons/ico_change_location.png" class="valign" /><div class="txt_valign"><?=$this->translate('Change location'); ?></div></a>
                </div>
            <div class="clearer"></div>    
            <div class="advertising">
                <!-- BEGIN PARTNER PROGRAM - DO NOT CHANGE THE PARAMETERS OF THE HYPERLINK -->
                <script language="javascript" type="text/javascript" src="http://program.epartner.es/view.asp?ref=570686&site=8346&type=html&hnb=5&js=1"></script>
                <noscript><a href="http://web.epartner.es/click.asp?ref=570686&site=8346&type=b1&bnb=1" target="_blank">
                <img src="http://program.epartner.es/view.asp?ref=570686&site=8346&b=1" border="0"/></a><br /></noscript>
                <!-- END PARTNER PROGRAM -->
            </div>
        </div>
</div> <!-- /main -->
